package com.unit.testng.parameter;

import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

/**
 * @author bigFish
 * @Title: xml文件传参
 */
public class ParameterTest {

    //    参数化测试只能运行Xml文件
    @Test
    @Parameters({"name", "age"})
    public void testXml(String name, String age) {
        System.out.println("这是使用Xml文件传值。name:[" + name + "],age:[" + age + "]");
    }


    public static void main(String[] args) {
        ParameterTest parameterTest = new ParameterTest();
        while (true) {
            System.out.println("请输入名字与年龄，参数用用‘,’分隔。输入多组数据请用‘;’分隔");
            System.out.println("退出请输入q：");
            Scanner scan = new Scanner(System.in);
            String str = scan.next();
            if (str.equals("q")) {
                break;
            }
            String[] a = str.split(";");
            for (int j = 0; j < a.length; j++) {
                String s = a[j];
                String[] split = s.split(",");
                for (int i = 0; i < 1; i++) {
                    parameterTest.testXml(split[0], split[1]);
                }
            }

        }
    }
}
